package com.sw.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sw.dao.AddressManageDao;
import com.sw.model.AddressManage;
import com.sw.service.AddressManageService;

@Service
public class AddressManageServiceImpl implements AddressManageService {

	@Autowired
	private AddressManageDao addressManageDao;
	
	@Override
	public boolean insertAddress(AddressManage adderss) {
		boolean flag = false;
		try {
			int i = addressManageDao.insertAddress(adderss);
			if(i > 0){
				flag = true;
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return flag;
	}

	@Override
	public boolean deleteAddressById(int id) {
		boolean flag = false;
		try {
			int i = addressManageDao.deleteAddress(id);
			if(i > 0){
				flag = true;
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return flag;
	}

	@Override
	public boolean updateAddress(AddressManage adderss) {
		boolean flag = false;
		try {
			int i = addressManageDao.updateAddress(adderss);
			if(i > 0){
				flag = true;
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return flag;
	}

	@Override
	public List<AddressManage> getAddressAll() {
		List<AddressManage> list = addressManageDao.selectALL();
		if(list != null){
			return list;
		}
		return null;
	}

	@Override
	public AddressManage getById(int id) {
		AddressManage addressManage = addressManageDao.selectAddMan(id);
		if(addressManage != null){
			return addressManage;
		}
		return null;
	}

}
